package zhujie;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.reflect.Method;

public class TestCheck {
    public static void main(String[] args) throws IOException {
        Demo01 demo01 = new Demo01();
        Class cls = demo01.getClass();
        Method [] method = cls.getMethods();

        BufferedWriter bw = new BufferedWriter(new FileWriter("bug.txt"));
        for (Method method1 : method) {
            if(method1.isAnnotationPresent(Check.class)){
                try{
                    method1.invoke(demo01);
                }catch(Exception e){
                      bw.write(method1.getName());
                      bw.newLine();
                      bw.write(e.getCause().getMessage());
                    bw.newLine();
                    bw.write(e.getCause().getClass().getSimpleName());
                }
            }
        }

        bw.flush();
        bw.close();
    }
}
